﻿using System;
using System.Collections.Generic;
using System.Resources;
using System.Text;
using System.Reflection;
using System.Globalization;

namespace com.lover.common
{
    public class LocMgr
    {
        private static ResourceManager _resMgr;
        private static CultureInfo _culture;
        public static void initManager(string resName, string loc)
        {
            if (resName == null || resName == "") throw new Exception("必须指定语言资源名");
            if (loc == null || loc == "") loc = "zh_CN";
            
            _resMgr = new ResourceManager(resName, Assembly.GetExecutingAssembly());
            _culture = new CultureInfo(loc);
        }
        public static string getString(string key)
        {
            if (_resMgr == null) return "";
            try { return _resMgr.GetString(key, _culture); } catch { return "";}
        }
    }
}
